#pragma once

// incomplete linked list... what about the 0th element?

struct LinkedList
{
	int m_data;
	LinkedList * m_next;
	~LinkedList(){
		if(m_next)delete m_next;
	}
	LinkedList(int a_data):m_data(a_data),m_next(0){}
	LinkedList():m_data(0),m_next(0){}
	void add(int a_data){
		LinkedList * ptr = this;
		while(ptr->m_next != 0)
			ptr = ptr->m_next;
		LinkedList * newNode = new LinkedList(a_data);
		ptr->m_next = newNode;
	}
	int get(const int & a_index){
		LinkedList * ptr = this;
		for(int i = 0; i < a_index; ++i)
			ptr = ptr->m_next;
		return ptr->m_data;
	}
	int size(){
		int i = 1;
		LinkedList * ptr = this;
		while(ptr->m_next != 0){
			ptr = ptr->m_next;
			i++;
		}
		return i;
	}
};
